package stu.kurs.services.impl;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import stu.kurs.domain.User;
import stu.kurs.exceptions.ServiceException;
import stu.kurs.services.IUserService;
import stu.kurs.services.IRegistrationService;

@Stateless(name="RegistrationService")
public class RegistrationService implements IRegistrationService {
	
	@EJB(beanName="UserService")
	private IUserService  userService;

	public void registration(String email, String passwrod) throws ServiceException {
		System.err.println("---------------------RegistrationService---------------------");
		User user = new User(email, userService.getMD5(passwrod));
		userService.save(user);
	}
	
	public boolean checkEmail(String email) throws ServiceException{
		if (userService.findByEmail(email) != null) return true;
		else return false;
	}

}
